package com.taoyibao.hongcanting.ui.mine.views;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.widget.TextView;

import com.taoyibao.hongcanting.R;
import com.taoyibao.hongcanting.base.BaseRelativeLayout;
import com.taoyibao.hongcanting.constant.CodeConstant;
import com.taoyibao.hongcanting.model.WalletDetailModel;
import com.taoyibao.hongcanting.utils.CodeUtils;

/**
 * @author TangAnna
 * @description: 钱包明细的Item
 * @date :${DATA} 10:11
 */
public class ItemWalletDetailsArea extends BaseRelativeLayout<WalletDetailModel> {
    /**
     * 分类
     */
    private TextView mTvType;

    /**
     * 时间
     */
    private TextView mTvTime;
    /**
     * 金额
     */
    private TextView mTvAmount;

    public ItemWalletDetailsArea(Context context) {
        super(context);
    }

    public ItemWalletDetailsArea(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ItemWalletDetailsArea(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void initView(Context context, AttributeSet attrs, int defStyleAttr) {
        mTvType = findViewById(R.id.tv_itemWalletDetail_type);
        mTvTime = findViewById(R.id.tv_itemWalletDetail_time);
        mTvAmount = findViewById(R.id.tv_itemWalletDetail_amount);
    }

    @Override
    public void setData(WalletDetailModel data) {
        //时间
        if (!TextUtils.isEmpty(data.order_addtime)) {
            mTvTime.setText(data.order_addtime);
        }

        //金额和 分类
        switch (data.type) {
            case CodeConstant.STATUS_WALLET_EAT://就餐
                mTvAmount.setTextColor(CodeUtils.getIdColor(R.color.color666));
                mTvAmount.setText("-" + CodeUtils.formatAmount2String(data.order_totalmoney));
                mTvType.setText(CodeUtils.getIdString(R.string.string_eat) + "-" + data.order_companyname);
                break;
            case CodeConstant.STATUS_WALLET_HELP_PAY://帮结账
                mTvAmount.setTextColor(CodeUtils.getIdColor(R.color.color666));
                mTvAmount.setText("-" + CodeUtils.formatAmount2String(data.order_totalmoney));
                mTvType.setText(CodeUtils.getIdString(R.string.string_helpPayType) + "-" + data.order_companyname);
                break;
            case CodeConstant.STATUS_WALLET_DASHANG://打赏
                mTvAmount.setTextColor(CodeUtils.getIdColor(R.color.color666));
                mTvAmount.setText("-" + CodeUtils.formatAmount2String(data.order_totalmoney));
                mTvType.setText(CodeUtils.getIdString(R.string.string_daShang) + "-" + data.order_companyname);
                break;
            case CodeConstant.STATUS_WALLET_RECHARGE://充值
            case CodeConstant.STATUS_WALLET_ALL://全部的时候
                mTvAmount.setTextColor(CodeUtils.getIdColor(R.color.colorf46));
                mTvAmount.setText("+" + CodeUtils.formatAmount2String(data.order_totalmoney));
                mTvType.setText(CodeUtils.getIdString(R.string.string_recharge));
                break;
            case CodeConstant.STATUS_WALLET_RECHARGE_ALIPAY://充值_支付宝
                mTvAmount.setTextColor(CodeUtils.getIdColor(R.color.colorf46));
                mTvAmount.setText("+" + CodeUtils.formatAmount2String(data.order_totalmoney));
                mTvType.setText(CodeUtils.getIdString(R.string.string_recharge) + " - 支付宝");
                break;
            case CodeConstant.STATUS_WALLET_HELP_PAY_WECHART://充值_微信
                mTvAmount.setTextColor(CodeUtils.getIdColor(R.color.colorf46));
                mTvAmount.setText("+" + CodeUtils.formatAmount2String(data.order_totalmoney));
                mTvType.setText(CodeUtils.getIdString(R.string.string_recharge) + " - 微信");
                break;
            case CodeConstant.STATUS_WALLET_WITHDRAW://提现
                mTvAmount.setTextColor(CodeUtils.getIdColor(R.color.color666));
                mTvAmount.setText("-" + CodeUtils.formatAmount2String(data.order_totalmoney));
                mTvType.setText(CodeUtils.getIdString(R.string.string_withdraw) + " - 支付宝");
                break;
            case CodeConstant.STATUS_WALLET_FANLI://返利
                mTvAmount.setTextColor(CodeUtils.getIdColor(R.color.colorf46));
                mTvAmount.setText("+" + CodeUtils.formatAmount2String(data.order_totalmoney));
                mTvType.setText(CodeUtils.getIdString(R.string.string_fanLi));
                break;
        }
    }

    @Override
    protected int bindLayout() {
        return R.layout.item_wallet_detail;
    }
}
